package name.cyrax.red.jpv.impl.vectors;

import name.cyrax.red.jpv.api.adapters.NumericAccessor;
import name.cyrax.red.jpv.api.funcs.FunctorInstance;
import name.cyrax.red.jpv.api.funcs.info.ValueType;
import name.cyrax.red.jpv.api.vectors.VectorFactory;
import name.cyrax.red.jpv.impl.funcs.DefaultFunctorInstances;

public abstract class DoubleVectorImpl extends VectorImpl<Double>
{

	@Override public VectorFactory<Double> factory()
	{
		return VectorFactories.getDouble();
	}

	@Override public <T> T detectType(NumericAccessor<T> accessor)
	{
		return accessor.asDouble(asDouble());
	}

	@Override public int getInteger(int index)
	{
		return (int) getDouble(index);
	}

	@Override public long getLong(int index)
	{
		return (long) getDouble(index);
	}

	@Override public abstract double getDouble(int index);

	@Override public Double getNumber(int index)
	{
		return getDouble(index);
	}
	
	@Override public FunctorInstance getFunctorInstance()
	{
		return FUNC_INST; 
	}

	private static final FunctorInstance FUNC_INST = DefaultFunctorInstances.VECTOR.getFunctorInstance(
		DefaultFunctorInstances.FUNCTOR_STUB_VECTOR, null, ValueType.DOUBLE);
}
